package com.cloud.service.user.impl;

import com.cloud.domain.user.User;
import com.cloud.mapper.user.UserMapper;
import com.cloud.service.user.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author liuyuan
 * @since 2019-11-18
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Autowired
    UserMapper userMapper;


    @Override
    public User getByAccountName(String accountName) {
        if(StringUtils.isBlank(accountName)){
            return null;
        }
        Map<String, Object> query = new HashMap<>();
        query.put("account_name",accountName);
        List<User> users = userMapper.selectByMap(query);
        if(users.size() == 0){
            return null;
        }
        return users.get(0);
    }
}
